<?php 

/*	Author: Gustavo Palacios
	Author: Fernando Rodas

	Project: EPS, Ciencias y Sistemas, USAC. 2014-2015	
	*/
	
		?>
<!DOCTYPE html>
<html>
    <?php
	require_once("clases/funciones_2.php");
	$plantilla = new Funciones_2;
	echo $plantilla->headerAdmin("Proceso de produccion - CEMA","Sistema de costos","Agregar Actividades","Actividades"); 
	?>
	<head>
	<link href="css/multi-select.css" media="screen" rel="stylesheet" type="text/css">
	  <!-- jQuery 2.0.2 -->
        <script src="js/jquery.min.js"></script>
		
	<script type="text/javascript" language="javascript" charset="utf-8">
var idCate = 0;
	function calcular()
	{
	
	var value1 = document.getElementById('cantidad').value;
    var value2 =document.getElementById('unitario').value;
	
	$("#total").val(value1 * value2);
	
	}
	
	window.onload=inicial();

function inicial()
{
Procesos();

}
function Procesos()
{
var fd = new FormData();
fd.append("tipo", "6");
fd.append("id_ca", <?php echo $_GET["id"];?>);
	$.ajax({
url: "clases/calculos.php",
type: "POST",
data:  fd,
contentType: false,
cache: false,
processData:false,
success: function(data){
$("#insum").html(data);

},
error: function(){} 	        
});

}

	$(document).ready(function() {
$("#uploadForm").on('submit',(function(e){
e.preventDefault();
var fd = new FormData(this);
fd.append("tipo", "7");
fd.append("id_ca", <?php echo $_GET["id"];?>);
$.ajax({
url: "clases/calculos.php",
type: "POST",
data:  fd,
contentType: false,
cache: false,
processData:false,
success: function(data){
$("#test").html(data);
$("#concepto").val("");
$("#unidad").val("");
$("#cantidad").val("");
$("#unitario").val("");
$("#total").val("");
Procesos();
},
error: function(){} 	        
});

}));
});

function eliminar() {

	var fd = new FormData();
					fd.append("idCate", idCate);
					fd.append("tipo", "8");
					$.ajax({
					url: "clases/calculos.php",
					type: "POST",
					data:  fd,
					contentType: false,
					cache: false,
					processData:false,
					beforeSend: function () {
					
					},
					success: function(data){
					$("#test").html(data);
					$('#borrarCategoria').modal('hide');
					$("#categoria-producto").html("");
					$("#test2").html("");
					Procesos();
					},
					error: function(){} 	        
					});	

}

</script>

</head>


                <!-- Main content -->
                <section class="content">
					<div id="test">
					
					</div>
					
					
					<!--Comienzo de la tabla -->
					<div class="row">
                        <div class="col-xs-12">
						
						<div class="box">
                                <div class="box-header">
                                    <h3 class="box-title">Ingreso de Actividades</h3>
											<br>
										
                                </div><!-- /.box-header -->
						
                                <div class="box-body table-responsive">
									<center>
									<h4> Insumo Numero: <?php echo $_GET["id"];?> </h4>
									</center>
									
									  <form id="uploadForm"  method="post">
									 <div class="form-group">
								   <table class="table table-bordered table-striped table-condensed">
                                        <thead>
                                            <col width="30%">
                                            
                                           
                                        </thead>
                                        <tbody>
											<tr>
                                                <td><b>Concepto:</b></td>
                                                <td><center> <input type="text" class="input" style="width:90%; height:25px;" id="concepto" name="concepto" required></center></td>
											</tr>
											 <tr>
                                                <td><b>Unidad de medida:</b></td>
											<td><center> <input type="text" class="input" style="width:90%; height:25px;" id="unidad" name="unidad" required></center></td>

											 </tr>
											 <tr>
                                                <td><b>Cantidad:</b></td>
                                                <td><center> <input type="number" class="input" onchange="calcular()" step="any" style="width:90%; height:25px;" id="cantidad" name="cantidad" required></center></td>
											 </tr>
											 <tr>
                                                <td><b>Costo Unitario:</b></td>
                                                <td><center> 
											<input type="number" class="input" style="width:90%; height:25px;" onchange="calcular()" step="any" id="unitario" name="unitario" required></center></td>
											 </tr>
											 <tr>
                                                <td><b>Costo Total:</b></td>
                                                <td><center>
											<input type="number" class="input" style="width:90%; height:25px;" step="any" id="total" name="total" readOnly></center></td>
											 </tr>
                                        </tbody>
                                    </table>
									
									<br>
									<div align="right">

									        <button type="submit" class="btn btn-xs  btn-default " name="agregarNoticia">

									Agregar &nbsp;<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 
									</button>
									
									</div>
									</div>
									
									</form>
									<br><br>
									
									<div id="insum">
									</div>
									
									
									<br><br>
									<div align="right">
									
									
									<a href="obra_alevin.php"><button type="button" class="btn btn-lg  btn-success  " data-toggle="tooltip" data-placement="top" title="Guardar y Salir">
									<span class="glyphicon glyphicon-floppy-saved" aria-hidden="true"></span> 
									</button></a>
								
									
									</div>
                                </div><!-- /.box-body -->
                            </div><!-- /.box -->
						
						</div>
						
						</div>
			
					
					<!--Fin tabla -->
				

                </section><!-- /.content -->
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->
<!-- Button trigger modal -->

<!------------------------------------ MODAL PARA ELIMINAR Usuario  ----------------------------------------->
					<div class="modal fade" id="borrarCategoria" tabindex="-1" role="dialog" aria-labelledby="borrarProductoLabel" aria-hidden="true">
						<div class="modal-dialog">
						<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cerrar</span></button>
					<h4 class="modal-title" id="myModalLabel">Eliminar</h4>
				</div>
				<div class="modal-body">
				
				<h3><i class="fa fa-warning text-yellow"></i> Esta Seguro que desea quitar actividad?</h3>
				
				</div>
				
				<div class="modal-footer">
					<button class="btn btn-primary" onclick="eliminar()">Aceptar</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
				</div>
				</div>
				</div>
			</div>'

<!------------------------------------FINAL MODAL PARA ELIMINAR USUARIO  ----------------------------------------->



      
        <!-- Bootstrap -->
        <script src="js/plugins/bootstrap.min.js" type="text/javascript"></script>
        <!-- AdminLTE App -->
        <script src="js/plugins/AdminLTE/app.js" type="text/javascript"></script>
		  <!-- DATA TABES SCRIPT -->
        
    </body>
		<script type="text/javascript">
		 	function enviarCategoria(categoria){
			window.idCate = categoria;
			}
	 
	
	 </script>
	<?php
	echo $plantilla->footerAdmin();
	?>
</html>